/*
 * @Author: ellery
 * @Date: 2022-08-21 18:27:24
 * @LastEditTime: 2022-08-21 19:42:55
 * @LastEditors: ellery
 * @Description:暴露axios请求器
 * @FilePath: \vue2-eslint-model\src\api\puapi.js
 * Copyright (c) 2022 by ellery, All Rights Reserved.
 * 愿天堂没代码
 */
import Api from "./api";

const METHODS = ["$catch", "$on", "$once", "$off"];
const API = {
  install(Vue, options) {
    const api = new Api(options);
    try {
      Vue.prototype.$api = api;
    } catch (_) {
      Vue.config.globalProperties.$api = api;
    }
    METHODS.forEach((key) => {
      this[key] = api[key].bind(api);
    });
    this.$api = api;
  }
};
export default API;
